package com.tyk.bookstore.front.member.util;


import com.tyk.bookstore.front.member.model.entity.DeliveryAddressDo;
import com.tyk.bookstore.front.member.model.entity.MemberDetailDo;
import com.tyk.bookstore.front.member.model.entity.MemberDo;
import com.tyk.bookstore.front.member.model.query.DeliveryAddressAddQuery;
import com.tyk.bookstore.front.member.model.query.DeliveryAddressUpdateQuery;
import com.tyk.bookstore.front.member.model.query.MemberUpdateQuery;
import com.tyk.bookstore.front.member.model.vo.DeliveryAddressVo;
import com.tyk.bookstore.front.member.model.vo.MemberVo;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;

import java.util.List;

@Mapper(componentModel = "spring")
public interface MapStructMember {
    MemberVo toMemberVo(MemberDo member, MemberDetailDo memberDetail);


    @Mappings({
            @Mapping(target = "memberId", ignore = true),
            @Mapping(target = "avatar", ignore = true),
            @Mapping(target = "idCard", ignore = true)})
    MemberDetailDo toMemberDetailDo(MemberUpdateQuery query);


    @Mappings({
            @Mapping(target = "areaCodeList", ignore = true),
            @Mapping(target = "areaFullName", ignore = true),
    })
    DeliveryAddressVo toDeliveryAddressVo(DeliveryAddressDo deliveryAddress);

    List<DeliveryAddressVo> toDeliveryAddressVoList(List<DeliveryAddressDo> doList);


    @Mappings({
            @Mapping(target = "id", ignore = true),
            @Mapping(target = "memberId", ignore = true),
            @Mapping(target = "defaulted", ignore = true)
    })
    DeliveryAddressDo toDeliveryAddressDo(DeliveryAddressAddQuery query);


    @Mappings({
            @Mapping(target = "memberId", ignore = true),
            @Mapping(target = "defaulted", ignore = true)
    })
    DeliveryAddressDo toDeliveryAddressDo(DeliveryAddressUpdateQuery query);
}
